﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class LootTable : MonoBehaviour
{
    [SerializeField]
    protected Loot[] loot;
    public List<Drop> MyDroppedItems{ get; set; }
    
    protected bool gotRolled=false;
    protected virtual void RollLoot()
    {

        foreach (Loot item in loot)
        {
            int luck = Random.Range(0, 100);
            if (luck <= item.MyDropChanse)
            {
                MyDroppedItems.Add(new Drop(item.MyItem,this));
            }
        }
        gotRolled = true;
    }

    public virtual List<Drop> ShowLoot()
    {
        
        if (!gotRolled)
        {
            MyDroppedItems = new List<Drop>();
            RollLoot();
        }
        
        //LootWindow.MyInstance.CreatePages(MyDroppedItems);
        return MyDroppedItems;
    }
}
